package org.exhaust.framework.net.common.protocol;

import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.net.InetSocketAddress;

@Data
public class BaseUdpFrame extends BaseFrame {

    private BaseFrame frame;

    public BaseUdpFrame() {
    }

    public BaseUdpFrame(BaseFrame frame) {
        this.frame = frame;
    }

    protected InetSocketAddress recipient;

    protected InetSocketAddress sender;

    @Override
    protected void encodeData(ByteBuf out) {
        if (this.frame != null) {
            this.frame.encodeData(out);
        }
    }

    @Override
    public void decode(ByteBuf in, FrameHeader header) {
        if (frame != null) {
            frame.decode(in, header);
        }
    }

}
